//
//  LFWeakTimerObject.swift
//  ImageLoopDemo
//
//  Created by 夏灵烽 on 2025/1/9.
//

import UIKit

class LFWeakTimerObject: NSObject {
    
    weak var target: NSObject?
    var selector: Selector?
    
    class func scheduledTimer(timeInterval ti: TimeInterval, target aTarget: Any, selector aSelector: Selector, userInfo: Any?, repeats yesOrNo: Bool) -> Timer {
        let weakObject = LFWeakTimerObject()
        weakObject.target = aTarget as? NSObject
        weakObject.selector = aSelector
        return Timer.scheduledTimer(timeInterval: ti, target: weakObject, selector: #selector(fireObject), userInfo: userInfo, repeats: yesOrNo)
    }
    
    @objc func fireObject(aTarget: Any) {
        
        target?.perform(selector)
    }

}
